// pages/reportImport/reportImport.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    addtime:'',
    rid:0
  },
  bindDateChange: function (e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      addtime: e.detail.value
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var rid = options.id;
    var that = this;
    if(rid){
      that.setData({
        rid: rid
      });
      wx.request({
        url: app.d.ceshiUrl + '/Api/Report/detail',
        method: "post",
        data: {
          rid:rid
        },
        header: {
          'Content-Type': 'application/x-www-form-urlencoded'
        },
        success: function (res) {
          console.log(res)
          if (res.data.status == 1) {
            that.setData({
              info: res.data.info,
              addtime:res.data.info.addtime
            });
          } else {
            wx.showToast({
              title: res.data.err,
            })
          }
        },
        fail: function (e) {
          wx.showToast({
            title: '网络异常！',
            duration: 30000
          });
        },
      })
    }
   
  },
  formBindsubmit:function (e) {
    var fdata = e.detail.value;
    var that = this;
    wx.request({
      url: app.d.ceshiUrl + '/Api/Report/add',
      method: "post",
      data: {
        rid:that.data.rid,
        uid:app.d.userId,
        xue: fdata.xue,
        hong: fdata.hong,
        xue_hong: fdata.xue_hong,
        ban: fdata.ban,
        bili: fdata.bili,
        bizhi: fdata.bizhi,
        lin_num: fdata.lin_num,
        shi_num: fdata.shi_num,
        xue_hong_non: fdata.xue_hong_non,
        xue_hong_num: fdata.xue_hong_num,
        hong_tiji: fdata.hong_tiji,
        niao_dan: fdata.niao_dan,
        niao_hong: fdata.niao_hong,
        niao_bai: fdata.niao_bai,
        bing: fdata.bing,
        yin: fdata.yin,
        niaotang: fdata.niaotang,
        gubin: fdata.gubin,
        gucao: fdata.gucao,
        zongdan: fdata.zongdan,
        baidang: fdata.baidang,
        gu_an: fdata.gu_an,
        zongdang: fdata.zongdang,
        zhijie: fdata.zhijie,
        ganxing: fdata.ganxing,
        xueniao: fdata.xueniao,
        xueji: fdata.xueji,
        sheng_qiu: fdata.sheng_qiu,
        xuetang: fdata.xuetang,
        zong_chuen: fdata.zong_chuen,
        ganyou: fdata.ganyou,
        gao_bai: fdata.gao_bai,
        jisuan: fdata.jisuan,
        ck: fdata.ck,
        rusuan: fdata.rusuan,
        jiatai: fdata.jiatai,
        aipei: fdata.aipei,
        tanglei: fdata.tanglei,
        tangleis: fdata.tangleis,
        yang: fdata.yang,
        gei_yang: fdata.gei_yang,
        dingxing: fdata.dingxing,
        niaosuan: fdata.niaosuan,
        gai: fdata.gai,
        jia: fdata.jia,
        lin: fdata.lin,
        lv: fdata.lv,
        na: fdata.na,
        eryang: fdata.eryang,
        addtime:that.data.addtime,
      },
      header: {
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      success: function (res) {
        console.log(res)
        if (res.data.status == 1) {
          wx.showToast({
            title: res.data.err,
            duration: 2000
          });
          setTimeout(function () {
            wx.navigateBack({

            })
          }, 2000)
        } else {
          wx.showToast({
            title: res.data.err,
          })
        }
      },
      fail: function (e) {
        wx.showToast({
          title: '网络异常！',
          duration: 30000
        });
      },
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})